package com.rui.shangXueTang.select;

/**
 * @author : [锐神NO.3]
 * @version : [v1.0]
 * @className : LinearSelect
 * @createTime : [2022/2/16 14:24]
 * @description : [线性查找]
 */

public class LinearSelect {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        int index = show(arr, 9);
        System.out.println(index);
    }

    private static int show(int[] arr, int target){
        for(int i = 0 ; i < arr.length ; i++){
            if(arr[i] == target){
                return i;
            }
        }
        return - 1;
    }
}
